﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AudioArrayControl : MonoBehaviour
{
    private AudioSource[] m_audioSource;
    private bool m_bLoop;
    // Start is called before the first frame update
    void Start()
    {
        m_audioSource = GetComponents<AudioSource>();
        if( m_bLoop == true )
        {
            int nIdx = Random.Range(0, m_audioSource.Length);
            m_audioSource[nIdx].Play();
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void PlayOnce()
    {
        int nIdx = Random.Range(0, m_audioSource.Length);
        m_audioSource[nIdx].Play();
    }
    public void PlayLoop()
    {
        m_bLoop = true;
    }
    public void StopAll()
    {
        foreach(AudioSource _src in m_audioSource)
        {
            _src.Stop();
        }
    }
}
